<?php
/**
 * Geneone: Content Management Framework
 * Ping Services
 *
 * http://geneone.neondragon.net/
 *
 * @package Geneone
 * @author Khlo
 * @version 1.0
 * @copyright 2004-2006 Geneone Development Team
 */
 
require_once ("Gene/XML/RPC.php");
 
class Gene_Object_Ping {
	/**
	 * Object ID
	 *
	 * @var integer
	 */
	var $objectId;
	
	/**
	 * Class Constructor
	 *
	 * @var integer $objectId Object ID
	 * @var integer $setId Taxonomy Set ID
	 */
	function Gene_Object_Ping($objectId) {
		$this->objectId = $objectId;
	}
	
	/**
	 * Ping services.
	 *
	 * @return integer Number of services pinged.
	 */
	function ping() {
		$object =& Gene_Object::get($this->objectId);
		$info = $object->get();
		
		if ($object->getProperty('pingServices')) {
			$services = explode("\n", $object->getProperty('pingServices'));
			$pinged = 0;
			
			if (count($services)) {
				foreach ($services as $i) {
					$req =& new Gene_XML_RPC($i);
					if ($req->query('weblogUpdates.ping', $info['title'], Gene::makeLink($info))) {
						$pinged++;
					}
				}
				
				return $pinged;
			} else {
				return 0;
			}
		} else {
			return 0;
		}
	}	
}
 
?>